package com.ruoyi.workbench.service.impl;

import java.util.List;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.workbench.domain.WorkMatter;
import com.ruoyi.workbench.dto.MatterSummary;
import com.ruoyi.workbench.mapper.WorkMatterMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.workbench.mapper.WorkMatterSummaryMapper;
import com.ruoyi.workbench.domain.WorkMatterSummary;
import com.ruoyi.workbench.service.IWorkMatterSummaryService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 事项总结Service业务层处理
 *
 * @author Guojl
 * @date 2024-07-06
 */
@Service
public class WorkMatterSummaryServiceImpl implements IWorkMatterSummaryService
{
    @Autowired
    private WorkMatterSummaryMapper workMatterSummaryMapper;

    @Autowired
    private WorkMatterMapper workMatterMapper;

    /**
     * 查询事项总结
     *
     * @param workSummaryId 事项总结主键
     * @return 事项总结
     */
    @Override
    public WorkMatterSummary selectWorkMatterSummaryByWorkSummaryId(Long workSummaryId)
    {
        return workMatterSummaryMapper.selectWorkMatterSummaryByWorkSummaryId(workSummaryId);
    }

    /**
     * 查询事项总结列表
     *
     * @param workMatterSummary 事项总结
     * @return 事项总结
     */
    @Override
    @DataScope(deptAlias = "zj", userAlias = "zj")
    public List<MatterSummary> selectWorkMatterSummaryList(WorkMatterSummary workMatterSummary)
    {
        return workMatterSummaryMapper.selectWorkMatterSummaryList(workMatterSummary);
    }

    /**
     * 新增事项总结
     *
     * @param workMatterSummary 事项总结
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = RuntimeException.class)
    public int insertWorkMatterSummary(WorkMatterSummary workMatterSummary)
    {
        workMatterSummaryMapper.insertWorkMatterSummary(workMatterSummary);
        WorkMatter workMatter = new WorkMatter();
        workMatter.setMatterId(Integer.valueOf(workMatterSummary.getWorkMatterId().toString()));
        workMatter.setEm1("已完成");
        workMatter.setEm4("4");
        return workMatterMapper.update(workMatter);
    }

    /**
     * 修改事项总结
     *
     * @param workMatterSummary 事项总结
     * @return 结果
     */
    @Override
    public int updateWorkMatterSummary(WorkMatterSummary workMatterSummary)
    {
        return workMatterSummaryMapper.updateWorkMatterSummary(workMatterSummary);
    }

    /**
     * 批量删除事项总结
     *
     * @param workSummaryIds 需要删除的事项总结主键
     * @return 结果
     */
    @Override
    public int deleteWorkMatterSummaryByWorkSummaryIds(Long[] workSummaryIds)
    {
        return workMatterSummaryMapper.deleteWorkMatterSummaryByWorkSummaryIds(workSummaryIds);
    }

    /**
     * 删除事项总结信息
     *
     * @param workSummaryId 事项总结主键
     * @return 结果
     */
    @Override
    public int deleteWorkMatterSummaryByWorkSummaryId(Long workSummaryId)
    {
        return workMatterSummaryMapper.deleteWorkMatterSummaryByWorkSummaryId(workSummaryId);
    }
}
